package top.hzy520.shopcart.dto;

import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 8:51 2018/6/13
 */
@Data
public class ShopCartOutputDto implements Serializable {
  private BigDecimal totalFavourablePrice;
  private Integer totalChooseSkuQuantity;
  private BigDecimal shopCartTotalPrice;
  private List<ProductSkuOutputDto> skuOutputDtoList;
  /**
  *@Author: HouZeYu
  *@Description: 购物车对象转map
  *@Date: 12:08 2018/6/13
  */
  public Map<String,Object> toMap(){
    Map<String,Object> map=new HashMap<>();
    map.put("shopCartTotalPrice",this.shopCartTotalPrice);
    map.put("skuOutputDtoList",this.skuOutputDtoList);
    map.put("totalChooseSkuQuantity",this.totalChooseSkuQuantity);
    map.put("totalFavourablePrice",this.totalFavourablePrice);
    return map;
  }
  /**
  *@Author: HouZeYu
  *@Description: map转购物车对象
  *@Date: 12:09 2018/6/13
  */
  public static ShopCartOutputDto fromMap(Map<String,Object> map){
    ShopCartOutputDto shopCartOutputDto=new ShopCartOutputDto();
    shopCartOutputDto.setShopCartTotalPrice((BigDecimal) map.get("shopCartTotalPrice"));
    shopCartOutputDto.setSkuOutputDtoList((List<ProductSkuOutputDto>) map.get("skuOutputDtoList"));
    shopCartOutputDto.setTotalChooseSkuQuantity((Integer) map.get("totalChooseSkuQuantity"));
    shopCartOutputDto.setTotalFavourablePrice((BigDecimal) map.get("totalFavourablePrice"));
    return shopCartOutputDto;
  }
}
